
package ProOF.apl.problems.real.functions;

import ProOF.com.LinkerParameters;
import java.lang.Math;
/**
 *
 * @author Lucas
 */
public class RealFuncLM2 extends aRealFunction{
	
	@Override
	public void parameters(LinkerParameters link) throws Exception {

	}
	
	@Override
	public int dimension() {
		return 10;
	}
	
	@Override
	public double min( int i ) {
		return -5;
	}
	
	@Override
	public double max( int i ) {
		return 5;
	}

	@Override
	public double f(double[] x) throws Exception {
		check(x);
		double sum = 0;
		for (int i = 1; i < x.length - 1; i++) {
			sum += Math.pow(x[i]-1, 2)*(1+Math.pow(Math.sin(3*Math.PI*x[i+1]), 2));
		}
		return 0.1*(Math.pow(Math.sin(3*Math.PI*x[0]),2) + sum +
					Math.pow(x[9]-1, 2)*(1+Math.pow(Math.sin(2*Math.PI*x[9]), 2)));
	}

	@Override
	public String name() {
		return "LM2";
	}

	@Override
	public String description() {
		return "Levy and Montalvo 2 Problem";
	}	
}
